home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / try_qb / search.bas (.txt) < prev    next >
Encoding:
QuickBASIC Tokenized Source  |  1989-12-04  |  1.8 KB  |  30 lines

  1. FileName
  2. Pattern
  3. PACKETSIZE
  4. PatternLength
  5. FileLength
  6.     BytesLeft
  7. FileOffset
  8. Buffer
  9. Start
  10.     StringPos
  11. FoundIt
  12.  Default variable type is long integer.
  13. File to search: 
  14. Pattern to search for: "
  15.  Keep searching as long as there are enough bytes left in
  16.  the file to contain the pattern you're searching for:
  17.  Read either 10,000 bytes or the number of bytes left in the file,
  18.  whichever is smaller, then store them in Buffer$. (If the number,
  19.  of bytes left is less than PACKETSIZE, the following statemente
  20.  still reads just the remaining bytes, since binary I/O doesn'te
  21.  give "read past end" errors):
  22.  Find every occurrence of the pattern in Buffer$:r
  23.  Found the pattern, so print the byte position in the file
  24.  where the pattern starts:
  25. Found pattern at byte number
  26.  Find the byte position where the next I/O operation would take place,
  27.  then back up the file pointer a distance equal to the length of the
  28.  pattern (in case the pattern straddles a 10,000-byte boundary):
  29. Pattern not found.
  30.